package com.flyduck.modules.schedule.service.impl;

import com.flyduck.common.vo.PageResult;
import com.flyduck.common.vo.QueryVo;
import com.flyduck.modules.schedule.domain.SysScheduleJobLog;
import com.flyduck.modules.schedule.mapper.SysScheduleJobLogMapper;
import com.flyduck.modules.schedule.service.SysScheduleJobLogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: flyduck-admin
 * @description:
 * @author: flyduck
 * @create: 2020-06-16 16:55
 **/
@Service("sysScheduleJobLogService")
public class SysScheduleJobLogServiceImpl implements SysScheduleJobLogService {

    @Autowired
    private SysScheduleJobLogMapper sysScheduleJobLogMapper;

    /**
     * 保存日志
     * @param sysScheduleJobLog
     */
    @Override
    public void save(SysScheduleJobLog sysScheduleJobLog) {
        sysScheduleJobLogMapper.insert(sysScheduleJobLog);
    }

    /**
     * 定时任务日志页面数据查询
     * @param queryVo
     * @return
     */
    @Override
    public PageResult findPage(QueryVo queryVo) {
        PageHelper.startPage(queryVo.getPage(),queryVo.getRows());
        Page<SysScheduleJobLog> sysScheduleJobLogPage = sysScheduleJobLogMapper.findPage(queryVo.getKeyword());
        PageResult pageResult = new PageResult();
        pageResult.setTotal(sysScheduleJobLogPage.getTotal());
        pageResult.setRows(sysScheduleJobLogPage.getResult());
        return pageResult;
    }
}
